const Koa = require('koa')
const app = new Koa()
const Router = require('koa-router')
const cors = require('koa2-cors');
const router = new Router()
const koaBody = require('koa-body')

app.use(cors());

app.use(koaBody({
    multipart:true
}))

const env = 'test-2v0lw'

app.use(async (ctx,next)=>{
    ctx.state.env = env
    await next()
})

const playlist = require('./controller/playlist.js')
const swiper = require('./controller/swiper.js')
const blog = require('./controller/blog')
router.use('/playlist', playlist.routes())
router.use('/swiper', swiper.routes())
router.use('/blog', blog.routes())

app.use(router.routes())
app.use(router.allowedMethods())





app.listen(8080,()=>{
    console.log("服务开启在8080端口")
})